﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.IO;

namespace BaicaiTianqi.Model
{
    public class CityList
    {
        public static string getCityId(string city)
        {
            Stream input = Application.GetResourceStream(new Uri("citylist.txt", UriKind.Relative)).Stream;
            using (StreamReader sr = new StreamReader(input))
            {
                string item = String.Empty;
                while (sr.EndOfStream != true)
                {
                    item = sr.ReadLine();
                    if (item.Split('=')[1].Equals(city))
                    {
                        sr.Close();
                        input.Close();
                        return item.Split('=')[0];
                    }
                }
                sr.Close();
                input.Close();
                return "";
            }
        }
    }
}
